<!DOCTYPE html>
<html>
<head>
    <title>随机选择食物</title>
    <style>
        .selected-food {
            font-weight: bold;
            font-size: 24px;
            margin-top: 20px;
        }
        #result {
            display: none;
        }
        #food-list {
            overflow-y: auto;
            height: 200px;
            margin-top: 20px;
            border: 1px solid #ccc;
            padding: 10px;
        }
        #food-list span {
            display: block;
            line-height: 30px;
        }
    </style>
</head>
<body>
    <h1>随机选择食物</h1>
    <p>点击下方按钮开始/停止选择食物：</p>

    <button onclick="toggleSelection()" id="toggle-button">开始</button>

    <div id="result" class="selected-food"></div>

    <div id="food-list"></div>

    <script>
        var foods = ['汉堡', '披萨', '寿司', '炒饭', '面条', '烤肉', '火锅', '饺子', '豆浆油条', '沙拉'];
        var interval;

        function startSelection() {
            interval = setInterval(showRandomFood, 100);
            document.getElementById('toggle-button').textContent = '停止';
        }

        function stopSelection() {
            clearInterval(interval);
            document.getElementById('toggle-button').textContent = '开始';
            document.getElementById('food-list').innerHTML = '';
            document.getElementById('result').textContent = '选中的食物是：减肥不吃';
            document.getElementById('result').style.display = 'block';
        }

        function toggleSelection() {
            if (interval) {
                stopSelection();
            } else {
                startSelection();
            }
        }

        function showRandomFood() {
            var randomIndex = Math.floor(Math.random() * foods.length);
            var selectedFood = foods[randomIndex];

            var foodList = document.getElementById('food-list');
            foodList.innerHTML = '';
            
            var span = document.createElement('span');
            span.textContent = selectedFood;
            foodList.appendChild(span);
        }
    </script>
</body>
</html>